from ninja import Router

from apps.commom.user import InvitationRecordSerializer
from apps.schemas import R
from models.models import User
from utils.auth import AppletAuthBearer
from utils.decorators import handle_exception

invitation_record_router = Router(tags=["邀请记录"], auth=AppletAuthBearer())


@invitation_record_router.get("/invitation_records", summary="获取邀请记录")
@handle_exception("获取邀请记录失败")
def get_invitation_record(request):
    invite_users = User.objects.filter(invite_id=request.user.id)
    return R.ok(InvitationRecordSerializer(invite_users, many=True).data)
